<template>
<kb-layout title="咨询">
	<view class="tallk-page" >
		<view class="index-list">
		<view class="index" @click="()=>ee.jumpto('/pages/user/sendinfo')">
			<view class="face  radius bg-shoucang2">
				<text class="iconfont icon-shoucang2"></text>
			</view>
			<view class="content">
				<view class="c1">
					<view class="title">
						<u-text size="16" text="我发布的需求"> </u-text>
					</view>
					<view class="time">
						<text> {{demand.created_time}}</text>
					</view>
				</view>
				
				<view class="desc">
					<u-text size="13" lines="1" color="#999" :text="demand.title||'暂无发布'"> </u-text>
				</view>
			</view>
		</view>
		<!-- 我发布的需求end -->
		<!-- 浏览历史	 -->
		<view class="index"
		@click="()=>ee.jumpto('/pages/user/history')">
			<view class="face  radius bg-shijian">
				<text class="iconfont icon-shijian"></text>
			</view>
			<view class="content">
				<view class="c1">
					<view class="title">
						<u-text size="16" text="我的历史浏览记录"> </u-text>
					</view>
					<view class="time">
						<text>  {{history.last_time_label||''}}</text>
					</view>
				
				</view>
				<view class="desc">
					<u-text size="13" lines="1" color="#999" :text="history?.title||'暂无记录'"> </u-text>
				</view>	
			</view>
		</view>
		<!-- 浏览历史	 -->
	

		<view class="index" v-for="(item,index) in recentmsg" :key="index"
			@click="()=>ee.jumpto('/pages/tallk/tallk?toopenid='+ item.To_Account)">
			<view class="face">
				<up-avatar shape="square" size="50" :src="item.thumb"></up-avatar>
			</view>
			<view class="content">
				<view class="c1">
					<view class="title">
						<u-text size="16" :text="item.username"> </u-text>
					</view>
					<view class="time">
						<text>{{item.MsgTimeStamp}}</text>
					</view>
				</view>
				
				<view class="desc">
					<u-text size="13" lines="1" color="#999" :text="item.MsgShow"> </u-text>
				</view>
			</view>
		</view>
		<!-- 一个聊天人记录 -->
	</view>
</view>
</kb-layout>
</template>

<script>
	import util from "@/common/tools/utils.js";
	import {
		ims
	} from "./ims.js"
	export default {
		name: "tallIndex",
		data() {
			return {
				broker: {},
				recentmsg: [],
				history:{},
				demand:{},
			}
		},
		props:{
				refresh:{
					type: [Boolean, undefined]					
				}
		},
		watch:{
			refresh(o,v){
				console.log('refresh', v, o)
				if(o == true){
					this.recent_message();
				}
			}
		},
		methods: {
			recent_message: function() {
				this.ee.getBroker().then(ret => {
					this.broker = ret;
					return util.getModuleData("tallk/recent", {
						username: this.broker.openid
					})
				}).then(ret => {					 
					this.recentmsg = ret;
					return ret;
				}).then( ret => {
					util.getModuleData("webfront/lastview").then( ret =>{
						console.log('浏览记录', ret)
						if(ret){
							this.history = ret;
						}
					})
				}).then(ret => {
					if(this.broker.id){
						util.getModuleData("webfront/mydemand").then(ret =>{
							console.log('发布的需求', ret)
							if(ret.total>0){
									this.demand = ret.items[0]
							}
						})
					}
					
				})
			}
		},
		mounted() {
			this.recent_message()
			
			
		}
	}
</script>

<style lang="scss">
	.tallk-page{
		min-height: 1000rpx; 
	}
	.index:last-child .content {
		border-bottom: 0px solid #dedede;
	}
	.index-list{
		background-color: #fff;
		padding-top:44rpx;
	}
	.index {
		display: flex;
		flex-direction: row;
		padding: 10rpx 30rpx;
		background: #fff;
		
		& .face{
			min-width: 50px;
		}
	}

	.content {
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		flex-grow: 1;
		border-bottom: 1rpx solid #e9e9e9;
		padding-bottom: 22rpx;
		margin-left: 23rpx;
	}

	.c1 {
		flex-grow: 2;
		display: flex;
		justify-content: space-between;
	}

	.title {
		font-size: 32rpx;
	}

	.radius {
		width: 50px;
		height: 50px;
		display: flex;
		align-content: center;
		align-items: center;
		
		border-radius: 5px;
		justify-content: center;
		
		&.bg-shijian{
			background-color: #f37b1d;
		}

		& .icon-shijian::before {
			font-size: 28px;
			color: #fff;
			font-weight: bold;
			
		}
		&.bg-shoucang2{
			
			background-color: cadetblue;
		}
		& .icon-shoucang2{
			font-size: 28px;
			color: #fff;
		}
		  
	}

	.desc {
		color: #999;
		margin-top: 12rpx;
		font-size: 24rpx;
	}

	.time {
		color: #999;
		font-size: 24rpx;
	}
</style>